#include <algorithm>
#include <iostream>


using namespace std;
const int N = 2e5 + 5;
int now = 1, brr[N];
struct TR {
    int l, r, sum;
} tr[N * 32];
void build_tr(const int num, int LastTr, int l, int r) {
    if (l == r) {
        tr[now++] = {tr[LastTr].l, tr[LastTr].r, tr[LastTr].sum + 1};
        return ;
    }
    int mid = l + r >> 1;
    if (mid >= num) tr[now++] = {now, tr[LastTr].r, tr[LastTr].sum + 1}, build_tr(num, tr[LastTr].l, l, mid);
    else tr[now++] = {tr[LastTr].l, now, tr[LastTr].sum + 1}, build_tr(num, tr[LastTr].r, mid + 1, r);
}int n, m, gs;
int check(int k, int l, int r, int L, int R) {
    if (L == R) return L;
    int mid = L + R >> 1;
    int sum = tr[tr[r].l].sum - tr[tr[l].l].sum;
    if (sum >= k) return check(k, tr[l].l, tr[r].l, L, mid);
    return check(k - sum, tr[l].r, tr[r].r, mid + 1, R);
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; ++ i) {
        int num;
        cin >> num;
        brr[i] = now;
        build_tr(num, brr[i - 1], -1e9, 1e9);
    }
    for (int i = 1; i <= m; ++ i) {
        int l, r, k;
        cin >> l >> r >> k;
        cout << check(k, brr[l - 1], brr[r], -1e9, 1e9) << '\n';
    }

    return 0;
}